<?php

	include("common.php");
	
	if(!isset($_SESSION['tusername'])) exit;
	
	$result = mysql_query("SELECT * FROM `197_teacherdata` INNER JOIN `197_teachers` ON `197_teacherdata`.`teacher_id` = `197_teachers`.`teacher_id` WHERE `197_teacherdata`.`teacher_id` = " . $_SESSION['teacher_id']);
	$teacherdata = array();
	while($row = mysql_fetch_assoc($result)){
		array_push($teacherdata, $row);
	}
	
?>
<?php include("header.php"); ?>
<h1>老師管理區</h1>
<?php if(empty($teacherdata)){ ?>
	<p>目前沒有資料。</p>
<?php } else { ?>
	<ul>
		<?php foreach($teacherdata as $row){ ?>
			<li><?php echo $row['title']; ?> - [ <a href="teacherDataEdit.php?teacherdata_id=<?php echo $row['teacherdata_id']; ?>">編輯</a>｜<a href="teacherDataDelete.php?teacherdata_id=<?php echo $row['teacherdata_id']; ?>" onclick="return confirm('確定刪除？');">刪除</a> ]</li>
		<?php } ?>
	</ul>
<?php } ?>
<p><a href="teacherDataAdd.php">新增</a>｜<a href="teacherLogout.php">登出</a></p>
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>